package com.u.social.sale.controller;

import com.u.social.sale.service.ISeckillStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: u-social
 * @description: 秒杀控制器
 * @author: Alex Wu
 * @createDate: 2025-03-10 16:54
 **/

@RestController
@RequestMapping("/seckill")
public class SeckillController {

    @Autowired
    private ISeckillStockService seckillStockService;


    @RequestMapping("/status/product/{productId}")
    public String start(@PathVariable("productId") String productId) {
        System.out.println("start seckill");
        // 除了检查秒杀时间，还有随机路径
        return "start seckill";
    }

    @RequestMapping("/end")
    public String end() {
        return "end seckill";
    }

    @PostMapping("/kill")
    public String secKillProduct(@RequestParam("productId") Long productId) {
        seckillStockService.secKill(productId);
        return "kill success";
    }
}
